package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.vo.WeiboVo1;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiboMapper {
    //@Insert("Insert into weibo(content,created,user_id) values(#{content},#{created},#{userId})")
    void insertWeibo(Weibo weibo);

    //@Delete("delete from weibo where id=#{id}")
    int deleteById(Long id);

    //@Update("update weibo set content=#{content},created=#{created},user_id=#{userId} where id=#{id}")
    int updateById(Weibo weibo);

    /*
    * 单条数据全字段查询
    * 根据微博ID查询该条微博的所有信息
    * */
    //@Select("select id,content,created,user_id userId from weibo where id=#{id}")
    Weibo selectById(Long id);

    /*
    * 多条数据全字段查询
    * */
    //@Select("select id,content,created,user_id userId from weibo")
    List<Weibo> selectAll();

    /*
    * 查询部分字段的数据
    * 根据微博ID查询该条微博的内容和用户ID
    * */
    //@Select("select content,user_id userId from weibo where id=#{id}")
    WeiboVo1 selectByWeiboId(Long id);
}
